package interpreter.operation;

import interpreter.Memory;
import interpreter.Registers;

/**
 * @author Roderland
 * @since 1.0
 */
public enum Handler {
    HANDLER;

    public static void mov_imm_reg(int imm, Registers dest) {
        dest.setValue(imm);
    }

    public static void mov_reg_reg(Registers src, Registers dest) {
        dest.setValue(src.getValue());
    }

    public static void add_reg_reg(Registers src, Registers dest) {
        dest.setValue(src.getValue() + dest.getValue());
    }

    public static void mov_reg_mm(Registers src, int dest) {
        Memory.set(dest, src.getValue());
    }

    public static void mov_mm_reg(int src, Registers dest) {
        dest.setValue((int) Memory.get(src));
    }

    public static void push(Registers src) {
        Memory.set(Registers.ESP.getValue(), src.getValue());
        Registers.ESP.setValue(Registers.ESP.getValue() + 1);
    }

    public static void pop(Registers dest) {
        Registers.ESP.setValue(Registers.ESP.getValue() - 1);
        dest.setValue((int) Memory.get(Registers.ESP.getValue()));
    }

    public static void ret() {
    }
}
